package org.agile4j.patterns.callback;

public class HibernateTemplate {
	public void execute(CallBack action) {
		getConnection();
		action.doCRUD(); // 【i call you back】
		releaseConnection();
	}

	public void add() {
		execute( new CallBack() {
			public void doCRUD() {
				System.out.println("执行add操作...");
			}
		}); // 【you call me】
	}

	public void getConnection() {
		System.out.println("获得连接...");
	}

	public void releaseConnection() {
		System.out.println("释放连接...");
	}
}
